//
//  RequestTable.swift
//  TestProject
//
//  Created by 万想想 on 2020/8/19.
//  Copyright © 2020 edaili. All rights reserved.
//

import UIKit
import SQLite
class RequestTable {
    static let shareInstance = RequestTable.init()
    
    let response = Expression<String>.init("response")
    let currentTime = Expression<String>.init("currentTime")
    
    var table:Table?
    
    init() {
        table = SqLiteManger.shareInstance.createTable(tableName: "Table") { (bulider) in
            bulider.column(response)
            bulider.column(currentTime)
        }
    }
    
    
    func add(result: ResultModel){
        if SqLiteManger.shareInstance.insert(table: table, setters: [response <- result.response,currentTime <- result.currentTime]){
            print("成功")
        }
    }
    func select() -> [Row]{
        let rows = SqLiteManger.shareInstance.select(table: table,select: [response,currentTime]) ?? [Row]()
        return rows
    }
}
